package com.atung.parking.config.auth;


import com.atung.parking.config.auth.entity.AuthUserEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @author Administrator
 */
@Component
public class AuthUserMangerContext {

    public static Long getUserId() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        AuthUserEntity authUserEntity = (AuthUserEntity) (authentication.getPrincipal());
        return authUserEntity.getUserId();
    }

    public static AuthUserEntity getAuthUserEntity() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        AuthUserEntity authUserEntity = (AuthUserEntity) (authentication.getPrincipal());
        return authUserEntity;
    }
}
